import { Model, Node, Edge } from '@antv/x6/lib/model'
export type AbandonUndefine<T> = {
  [P in keyof T]-?: T[P]
}
export function toFromJson(data: Model.ToJSONData): Model.FromJSONData {
  const nodeArray: Node.Metadata[] = []
  const edgeArray: Edge.Metadata[] = []
  data.cells.forEach((cell) => {
    if (cell.shape?.indexOf('node') !== -1) {
      //表示为Node
      nodeArray.push(cell)
    } else {
      //表示为Edge
      // cell.source = {
      //   cell: cell.source.cell,
      //   port: cell.source.port,
      // }
      edgeArray.push(cell)
    }
  })
  return {
    nodes: nodeArray,
    edges: edgeArray,
  }

}
